package com.j283_5.wisdom_park.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.j283_5.wisdom_park.common.result.ResultData;
import com.j283_5.wisdom_park.mapper.CommentsMapper;
import com.j283_5.wisdom_park.pojo.Article;
import com.j283_5.wisdom_park.pojo.Comments;
import com.j283_5.wisdom_park.pojo.Person;
import com.j283_5.wisdom_park.service.CommentsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.List;

/**
 * <p>
 * 评论表 服务实现类
 * </p>
 *
 * @author laoda
 * @since 2022-04-28
 */
@Service
public class CommentsServiceImpl  implements CommentsService {

    @Resource
    private CommentsMapper commentsMapper;

    /**
     * 多条件查询评论
     * @param artId
     * @param Recently_Time
     * @return
     */
    @Override
    public ResultData findComments(Integer artId, Timestamp Recently_Time) {
        QueryWrapper<Comments> commentsQueryWrapper = new QueryWrapper<>();
        if (Recently_Time !=null){
            commentsQueryWrapper.eq("commSendTime",Recently_Time);
        }
        commentsQueryWrapper.eq("art_id",artId);
        List<Comments> comments = commentsMapper.selectList(commentsQueryWrapper);

        return ResultData.ok().data(comments);
    }


}
